home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / VGA_VUL4.ZIP / OUTLAW.TXT < prev   
Text File  |  1995-09-10  |  8KB  |  169 lines

  1.  
  2.       ┌───────────────────────────────────────────────────────────────╖
  3.       │■                                                            ■ ║
  4.       │                                                               ║
  5.       │  █████████░                   ██░                             ║
  6.       │  ██░    ██░ ██░   ██░ ██████░ ██░     ████████░ ██░     ██░   ║
  7.       │  ██░    ██░ ██░   ██░   ██░   ██░     ██░   ██░ ██░     ██░   ║
  8.       │  ██░    ██░ ██░   ██░   ██░   ██░     ████████░ ██░     ██░   ║
  9.       │  ██░    ██░ ██░   ██░   ██░   ██░     ██░   ██░ ██░ ██░ ██░   ║
  10.       │  █████████░ ████████░   ██░   ██████░ ██░   ██░  ███░ ███░    ║
  11.       │                                                               ║
  12.       │                        T ∙ R ∙ I ∙ A ∙ D                      ║
  13.       │■                                                            ■ ║
  14.       ╘═══════════════════════════════════════════════════════════════╝
  15.                                ╔══════════════╗
  16.                                ║ ∙ PRESENTS ∙ ║
  17.                                ╚══════════════╝
  18.  
  19.                         3D-ROTATIONS in 100% ASSEMBLER
  20. ───────────────────────────────────────────────────────────────────────────────
  21.  Code By      : Vulture                  Total Files  : 5
  22.  File Type    : 3d rotation source       Release Date : 10th of September '95
  23.  Difficulty   : Medium level             Filename     : VGA-VUL4.ARJ
  24. ───────────────────────────────────────────────────────────────────────────────
  25.  
  26.  Hello there. This is Vulture typing this little textfile. Yeah, uhm, well,
  27.  some of you might be confused since Outlaw Triad already released sources
  28.  covering 3d-rotations (VGA-VUL3). But, that source was coded in pascal
  29.  with some built-in assember and because a lotta people out there are more
  30.  interested in pure 100% asm, I thought it might be a good idea to release
  31.  my own little asm source-code covering 3d. This source was coded in IDEAL
  32.  mode. I'll assume basic knowledge of vga-coding, assembler and Pascal.
  33.  
  34. ───────────────────────────────────────────────────────────────────────────────
  35.  
  36.  Hmm, I am not gonna explain 3d-rotations in detail coz there are already
  37.  lotsa sources and explanations available. If you have a little experience
  38.  coding asm, you won't have too much trouble understanding the sourcecode.
  39.  In this textfile I'm just gonna provide you with the formulas needed to
  40.  rotate a point. These formulas use sine & cosine values. I will show you
  41.  how to create a sine-chart in Pascal. Also, when you have rotated a point,
  42.  you will need some formulas to display the point on the screen.
  43.  These formulas are also provided. Here they come:
  44.  
  45.  To rotate a point, use this:
  46.  
  47.  Rotate around x-axis
  48.  YT = Y * COS(xang) - Z * SIN(xang) / 256
  49.  ZT = Y * SIN(xang) + Z * COS(xang) / 256
  50.  Y = YT
  51.  Z = ZT
  52.  
  53.  Rotate around y-axis
  54.  XT = X * COS(yang) - Z * SIN(yang) / 256
  55.  ZT = X * SIN(yang) + Z * COS(yang) / 256
  56.  X = XT
  57.  Z = ZT
  58.  
  59.  Rotate around z-axis
  60.  XT = X * COS(zang) - Y * SIN(zang) / 256
  61.  YT = X * SIN(zang) + Y * COS(zang) / 256
  62.  X = XT
  63.  Y = YT
  64.  
  65.  Well, that's it. To see how you can rotate a point in assembler, examine
  66.  the source. It should not be that hard to understand. One thing that might
  67.  be a little confusing is the way the sine and cosine values are calculated.
  68.  Here's how I did it. I used a simple pascal procedure to calculate my sine
  69.  values. Here it comes:
  70.  
  71.  Procedure CalcSine;
  72.  Var I,Out: Integer;
  73.      An: Real;
  74.  Begin
  75.    For I := 0 to 255 Do                { 256 values }
  76.    Begin
  77.      An := I*(2*pi / 256);             { 2*pi coz of radians! }
  78.      Out := Round(Sin(An)*256);
  79.      Sine[I] := Out;                   { Save into array }
  80.    End;
  81.  End;
  82.  
  83.  Notice that this particular procedure saves the values into an array. What
  84.  you must do is change it so it saves the values to a file instead of an
  85.  array. The close reader might already have guessed that all values here
  86.  are integers. All values are multiplied with 256 and then rounded to an
  87.  integer value. In our rotation formulas you will see a divide by 256.
  88.  Should make perfect sense, shouldn't it? ;) I mean, 256 perfectly fits
  89.  into a byte. So we can use some fast asm-code in our rotationsource.
  90.  (sar=>see the source)
  91.  So, now you have a few sine-values. But, in the formula you also need
  92.  cosine-values. And those are not provided in this code, you might say...
  93.  Wrong! They are there. What you must do is add 64 to the degree to get
  94.  the cosine. Here's a little example:
  95.  
  96.  Suppose you have the degree 195.
  97.  To get the (co)sine-values out of the array, you would do this (in pascal):
  98.    SineValue := Sine[(195) Mod 256];      { Sine is the name of the array }
  99.    CosineValue := Sine[(195+64) Mod 256];
  100.  The degree value musn't get larger than 255. That's why we use a 'mod 256'
  101.  in our code. Take a look at the source to see how this is done in assembler.
  102.  
  103.  Ok, when you have rotated the point, you would like to put it on the screen
  104.  somehow, right? ;-) Well, you could use these formulas to do that:
  105.  
  106.  Xoff*X / Z+Zoff = Screen x
  107.  Yoff*Y / Z+Zoff = Screen y
  108.  
  109.  The Xoff & Yoff values are 256. But go and change them. It's fun!
  110.  The X,Y,Z values are those of the current 3d-point you are busy with.
  111.  Zoff is the distance to the viewer (howfar the object is away).
  112.  A large Zoff will produce just a small object (it's futher away) while
  113.  a small Zoff makes a big object. Zoff should not reach 0 coz then you
  114.  will get the strangest comments... "divide by zero" ... Weird huh? ;-)
  115.  But seriously, in the example Zoff is 300 but go change it and see
  116.  what happens. Best way to learn something is by trial and error.
  117.  Btw, I assume Screen x and Screen y don't need any explanation.
  118.  
  119.  Ok, that's all there is to it. Don't worry if you don't understand
  120.  any of it now. Just go and study this and other sources floating
  121.  around and you'll get the hang of it eventually.
  122.  
  123. ───────────────────────────────────────────────────────────────────────────────
  124.  
  125.  As always this source is not the best way to do 3d-rotations. It was
  126.  provided to help you on your way in the art of demo-coding. When you
  127.  have a little experience coding asm/vga, the source should not be
  128.  that hard to understand. Go and make some improvements on it.
  129.  Hint: try to insert a look-up table with all y-line offsets in it.
  130.  Hmm, but if you are a beginner vga-coder, I suggest you try some
  131.  simpler things instead. It's hard enough as it is...
  132.  Goodluck to ya and if ya make something nice with this code, please
  133.  let me know about it. I'm very interested!
  134.  
  135.  Btw, as always I'll take no responsibility if this code should damage
  136.  your computer, house, cat or sumthing. I've had no problems with it
  137.  and this code is free so go figure.
  138.  
  139.     Be seeing ya...
  140.  
  141.            Signed:    Vulture / Outlaw Triad
  142.  
  143.  
  144.  
  145. ─────────────────────────┬───────────────────────┬────────────────────────────
  146.  Outlaw Triad Distros :  │  Greetz from Outlaw:  │  Releases sofar:
  147. ─────────────────────────┼───────────────────────┼────────────────────────────
  148.                          │                       │
  149.  ■      The Force    ■   │   - DemoLisher        │   ■ MESSAGE  (dosscroller)
  150.  ■ +31 (0)36-5346967 ■   │   - ThunderHawk       │
  151.                          │   - Ash               │   ■ VGA-VUL1 (sources)
  152.                          │   - Trooper           │
  153.  ■     FireHouse     ■   │   - Rudeboy           │   ■ CHAINDOC (textfile)
  154.  ■ +31 (0)58-2661590 ■   │   - Utter Chaos       │
  155.                          │   - Crusher           │   ■ VGA-VUL2 (sources)
  156.                          │                       │
  157.  ■   Blue Nose Prod  ■   │   - Critical          │   ■ BASICDOC (textfile)
  158.  ■ +31 (0)345-619401 ■   │   - Da Frisian Force  │
  159.                          │   - Tribal            │   ■ VGA-VUL3 (sources)
  160.                          │   - Nailbomb          │
  161.                          │                       │   ■ VGA-VUL4 (sources)
  162.      open for more!      │   & all forgotten!    │
  163.                          │                       │   + various bbs-intros
  164. ─────────────────────────┴───────────────────────┴────────────────────────────
  165.  
  166.                    ■ (C) 1995  O∙U∙T∙L∙A∙W   T∙R∙I∙A∙D ■
  167.  
  168. ──────────────────────────────────────────────────────────────────────────────
  169.